#!/usr/bin/env python
#coding:utf-8
import sys
import time
import getpass
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException 

reload(sys)
sys.setdefaultencoding('utf-8')

browser = webdriver.Firefox()
browser.get('http://pachong.org/')

tr = browser.find_elements_by_xpath('/html/body/div[2]/table/tbody/tr')
for i in range(0, len(tr)):
	td_id   = tr[i].find_element_by_xpath('td[1]').text.strip()
	td_ip   = tr[i].find_element_by_xpath('td[2]').text
	td_port = tr[i].find_element_by_xpath('td[3]').text
	print '%s,%s:%s' % (td_id,td_ip, td_port)


'''
proxy_list = browser.find_elements_by_xpath('/html/body/div[2]/table/tbody/tr/td[2]')
print len(proxy_list)
for i in range(0, len(proxy_list)):
	print proxy_list[i].text

port_list = browser.find_elements_by_xpath('/html/body/div[2]/table/tbody/tr/td[3]')
print len(port_list)
for i in range(0, len(port_list)):
	print port_list[i].text
'''